package com.itheima.clollection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionTest03 {
    public static void main(String[] args) {
        Student student1 = new Student("王五",23);
        Student student2 = new Student("李四",21);
        Student student3 = new Student("坤坤",26);
        Student student4 = new Student("菜菜",22);

        Collection<Student> collection = new ArrayList();

        collection.add(student1);
        collection.add(student2);
        collection.add(student3);
        collection.add(student4);

        System.out.println(collection);

        Iterator<Student> iterator = collection.iterator();
        while (iterator.hasNext()){
            Student next = iterator.next();
            System.out.println(next);
        }

        System.out.println("-----------------");

        for (Student student : collection) {
            System.out.println(student);
        }
    }
}
